package com.aaa.ssm.controller;

import com.aaa.ssm.entity.Grade;
import com.aaa.ssm.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("grade")
@Api(tags = "班级管理")
public class GradeController {

    @ApiOperation(value = "获取所有班级")
    @GetMapping("list")
    public AjaxResult listAllGrades() {
        return AjaxResult.success(200, "获取成功");
    }

    @ApiOperation(value = "查询班级")
    @ApiImplicitParam(name = "id", value = "班级ID", required = true, dataType = "int")
    @GetMapping("query")
    public AjaxResult query(@RequestParam int id) {
        return AjaxResult.success(200, "获取成功");
    }

    @ApiOperation(value = "删除班级")
    @ApiImplicitParam(name = "id", value = "班级ID", required = true, dataType = "int")
    @DeleteMapping
    public AjaxResult deleteGrade( int id) {
        return AjaxResult.success(200, "删除成功");
    }

    @ApiOperation(value = "添加班级")
    @PostMapping
    public AjaxResult addGrade(@Validated Grade  grade) {
        return AjaxResult.success(200, "添加成功");
    }

    @ApiOperation(value = "更新班级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "班级ID", required = true, dataType = "int"),
            @ApiImplicitParam(name = "grade", value = "班级信息", required = true, dataType = "String")
    })
    @PutMapping
    public AjaxResult updateGrade(@RequestParam int id, @RequestParam String grade) {
        return AjaxResult.success(200, "更新成功");
    }
}